//
//  SubPlace.m
//  YouthOlympic2014
//
//  Created by Li Yuhang on 14-7-1.
//  Copyright (c) 2014年 mitian. All rights reserved.
//

#import "SubPlace.h"

@implementation SubPlace
@synthesize id,name,latitude,locationName,longtitude,picTag;

+(NSArray*/*Place*/) instanceList:(NSDictionary*) jsonData{
    NSArray *jsonSubPlaces = (NSArray*)jsonData[@"subLocation"];
    NSMutableArray* /*SubPlace*/ subplaces = [[NSMutableArray alloc]init];
    //
    for(int i=0; i< jsonSubPlaces.count ; i++){
        SubPlace* subplace = [[SubPlace alloc]init];
        NSDictionary* subplaceJson = jsonSubPlaces[i];
        subplace.id = subplaceJson[@"subLocationId"];
        subplace.name = subplaceJson[@"name"];
        subplace.longtitude = subplaceJson[@"lon"];
        subplace.latitude = subplaceJson[@"lat"];
        subplace.locationName = subplaceJson[@"locationName"];
        subplace.picTag = subplaceJson[@"pic"];
        [subplaces addObject:subplace];
    }
    
    return [NSArray arrayWithArray:subplaces];
}


- (UIImage*) icon{
    return [UIImage imageNamed:self.picTag];
}

-(NSString *)description{
    return [NSString stringWithFormat: @"{subLocationId:%@, name:%@}", self.id, self.name];
}


@end
